package com.dingwei.superiordiary.adapter.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.bean.Index_Bean;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created time 2018/3/26.
 * Creator 南柯一梦丶 on
 * Personal signature 余生还长 何必慌张
 * Page description :
 */

public class SignDayAdapter extends RecyclerArrayAdapter<String> {

    int day ;

    public SignDayAdapter(Context context,int day) {
        super(context);
        this.day = day;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup viewGroup, int i) {
        return new SignDayHolder(viewGroup);
    }


    class SignDayHolder extends BaseViewHolder<String> {


        @Bind(R.id.tv_point)
        TextView tvPoint;
        @Bind(R.id.tv_day)
        TextView tvDay;
        @Bind(R.id.line)
        View line;

        public SignDayHolder(ViewGroup parent) {
            super(parent, R.layout.item_sign);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(String data) {
            super.setData(data);

            switch (getDataPosition()){
                case 0:
                    tvPoint.setText("+10");
                    break;
                case 1:
                    tvPoint.setText("+20");
                    break;
                case 2:
                    tvPoint.setText("+30");
                    break;
                case 3:
                    tvPoint.setText("+40");
                    break;
                case 4:
                    tvPoint.setText("+50");
                    break;
                case 5:
                    tvPoint.setText("+60");
                    break;
                case 6:
                    tvPoint.setText("+70");
                    break;
            }

            tvDay.setText(""+(getDataPosition()+1));
            if (day>=(getDataPosition()+1)){
                tvDay.setTextColor(BaseActivity.context.getResources().getColor(R.color.sign_bg));
                tvDay.setBackgroundResource(R.drawable.cirle_w);
                line.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.white));
                if ((getDataPosition()+1) == day  ){
                    line.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.sign_bg));
                }

            }else {
                tvDay.setTextColor(BaseActivity.context.getResources().getColor(R.color.white));
                tvDay.setBackgroundResource(R.drawable.cirle_s);
                line.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.sign_bg));

            }

            if (getDataPosition()==6){
                line.setVisibility(View.GONE);
            }else {
                line.setVisibility(View.VISIBLE);
            }
        }
    }
}
